package com.aishare.qicaitaoke.base;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;

import com.aishare.qicaitaoke.broadcast.NetBroadcastReceiver;
import com.aishare.qicaitaoke.utils.ActivityUtil;
import com.aishare.qicaitaoke.utils.NetworkUtils;
import com.aishare.qicaitaoke.utils.StatusBarUtil;

public class BaseActivity extends AppCompatActivity  implements NetBroadcastReceiver.NetEvent{

    public static NetBroadcastReceiver.NetEvent netEvent;
    /**
     *
     * 网络类型
     */
    private int netMobile;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        ActivityUtil.INSTANCE.add(this);
        netEvent = this;

    }


    public boolean inspectNet(){
        this.netMobile = NetworkUtils.getNetWorkState(BaseActivity.this);
        return isNetConnect();
    }



    @Override
    public void onNetChange(int netMobile) {
        this.netMobile = netMobile;
        isNetConnect();
    }

    public boolean isNetConnect(){
        if(netMobile == 1){
            return true;
        } else if (netMobile == 0) {
            return true;
        }else if (netMobile == -1){
            return false;
        }

        return  false;
    }
}
